package com.corp.common.base.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;

/**
 * 继承BaseEntity和BaseEntity的对象,其数据库的is_deleted,create_time,update_time字段由数据库维护
 *
 * @Author Keanu
 * @Date 2020/7/16 0016 11:17
 * @Version
 **/
@Setter
@Getter
@Accessors(chain = true)
public class BaseEntity {
    /**
     * ID主键
     */
    @ApiModelProperty(value = "ID主键")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 逻辑删除标识(1-删除，0-未删除)
     */
    @TableLogic
    @ApiModelProperty(value = "逻辑删除标识(1-删除，0-未删除)", hidden = true)
    @TableField(value = "is_deleted")
    private Boolean deleted;
    /**
     * 记录创建的时间,由数据库设置默认值
     */
    @ApiModelProperty(value = "记录创建的时间")
    @TableField(insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
    private LocalDateTime createTime;
    /**
     * 记录修改的时间,由数据库更新该值
     */
    @ApiModelProperty(value = "记录修改的时间")
    @TableField(insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
    private LocalDateTime updateTime;
}
